﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace Citrix.XaAdminMobile.Model
{
    /// <summary>
    /// Model interface for querying XenApp sessions and getting notified when sessions are
    /// added/removed.
    /// </summary>
    internal interface ISessionsModel : INotifyPropertyChanged
    {
        /// <summary>
        /// Whether or not the model is currently loading new session state.
        /// </summary>
        bool IsLoading { get; }

        /// <summary>
        /// Returns the last error (if any) when loading session state. Null means the last load
        /// was successful.
        /// </summary>
        string LastLoadError { get; }

        /// <summary>
        /// Fired whenever a new session(s) has been detected, or when an existing session(s)
        /// has been removed. There is no automatic update of sessions. Session state is only
        /// updated when the <see cref="ISessionsModel.Refresh"/> method is called.
        /// </summary>
        event EventHandler<SessionsChangedArgs> SessionsChanged;

        /// <summary>
        /// Refreshes the current set of XenApp sessions. Existing session objects are kept if
        /// the associated session still exists. If any of the session state for existing
        /// sessions has changed then that session instance will fire notifications for the
        /// changed properties. If old sessions no longer exist, or new ones have been created
        /// then the <see cref="ISessionsModel.SessionsChanged"/> event will be fired.
        /// </summary>
        void Refresh();

        /// <summary>
        /// Resets the requested set of sessions.
        /// </summary>
        /// <param name="sessions">The set of sessions to reset.</param>
        void Reset(List<ISessionModel> sessions);

        /// <summary>
        /// Retrieves the current set of XenApp sessions. This set is only refreshed when you
        /// call <see cref="ISessionsModel.Refresh"/>.
        /// </summary>
        List<ISessionModel> Sessions { get; }
    }
}
